package com.jfsoft.config;

import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.session.SingleSignOutHttpSessionListener;
import org.jasig.cas.client.util.AssertionThreadLocalFilter;
import org.jasig.cas.client.util.HttpServletRequestWrapperFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.filter.DelegatingFilterProxy;

/**
 * @author ChenXc
 * @version V1.0
 * @Date 2018/3/16  16:03
 * @Description TODO(一句话描述类作用)
 */
@Configuration
@ImportResource(locations = {"classpath:sso-client.spring.xml"})
public class CasConfigure {


//    @Bean
//    public FilterRegistrationBean casAuthenticationFilter() {
//        FilterRegistrationBean casAuthenticationFilter = new FilterRegistrationBean();
//        casAuthenticationFilter.setFilter(new DelegatingFilterProxy());
//        casAuthenticationFilter.addInitParameter("targetBeanName", "authenticationFilter");
//        casAuthenticationFilter.addUrlPatterns("/authentication");
//        return casAuthenticationFilter;
//    }
//
//    @Bean
//    public FilterRegistrationBean casTicketValidationFilter() {
//        FilterRegistrationBean casTicketValidationFilter = new FilterRegistrationBean();
//        casTicketValidationFilter.setFilter(new DelegatingFilterProxy());
//        casTicketValidationFilter.addInitParameter("targetBeanName", "ticketValidationFilter");
//        casTicketValidationFilter.addUrlPatterns("/authentication");
//        return casTicketValidationFilter;
//    }
//
//    @Bean
//    public FilterRegistrationBean casHttpServletRequestWrapperFilter() {
//        FilterRegistrationBean casHttpServletRequestWrapperFilter = new FilterRegistrationBean();
//        casHttpServletRequestWrapperFilter.setFilter(new HttpServletRequestWrapperFilter());
//        casHttpServletRequestWrapperFilter.addUrlPatterns("/authentication");
//        return casHttpServletRequestWrapperFilter;
//    }
//
//    @Bean
//    public FilterRegistrationBean casAssertionThreadLocalFilter() {
//        FilterRegistrationBean casAssertionThreadLocalFilter = new FilterRegistrationBean();
//        casAssertionThreadLocalFilter.setFilter(new AssertionThreadLocalFilter());
//        casAssertionThreadLocalFilter.addUrlPatterns("/authentication");
//        return casAssertionThreadLocalFilter;
//    }
//
//    @Bean
//    public ServletListenerRegistrationBean servletListenerRegistrationBean(){
//        ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
//        servletListenerRegistrationBean.setListener(new SingleSignOutHttpSessionListener());
//        servletListenerRegistrationBean.setEnabled(true);
//        return servletListenerRegistrationBean;
//    }
//
//    @Bean
//    public FilterRegistrationBean singleSignOutFilter() {
//        FilterRegistrationBean singleSignOutFilter = new FilterRegistrationBean();
//        singleSignOutFilter.setFilter(new SingleSignOutFilter());
//        singleSignOutFilter.addUrlPatterns("/*");
//        return singleSignOutFilter;
//    }

}
